﻿Public NotInheritable Class SplashScreen

    Dim SQLDreader As SqlClient.SqlDataReader

    'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
    '  of the Project Designer ("Properties" under the "Project" menu).


    Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set up the dialog text at runtime according to the application's assembly information.  

        'TODO: Customize the application's assembly information in the "Application" pane of the project 
        '  properties dialog (under the "Project" menu).

        'Application title
        If My.Application.Info.Title <> "" Then
            'ApplicationTitle.Text = My.Application.Info.Title
            ApplicationTitle.Text = "Gulf Chemicals General Trading and Contracting Company. Kuwait"
        Else
            'If the application title is missing, use the application name, without the extension
            'ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
            ApplicationTitle.Text = "Gulf Chemicals General Trading and Contracting Company. Kuwait"
        End If

        'Format the version information using the text set into the Version control at design time as the
        '  formatting string.  This allows for effective localization if desired.
        '  Build and revision information could be included by using the following code and changing the 
        '  Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar.  See
        '  String.Format() in Help for more information.
        '
        '    Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)

        'Copyright.Text = My.Application.Info.Copyright
        Copyright.Text = "Retail Inventory Manager"

        'Copyright info
        'Version.Text = System.String.Format(Copyright.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)

        'If RegistrationKeyDLL.Registration.DetermineIfFileExists(733) = False Then
        '    Me.ShowInTaskbar = False
        '    Me.Hide()
        '    RegistrationMain.Show()
        '    Exit Sub
        'Else
        Me.ShowInTaskbar = True
        Me.Show()
        Me.BringToFront()
        'End If

    End Sub

    Function toCheckUserNameAndPassword() As Integer
        Try
            Dim ApData As New APdataLogic
            UserID = ApData.GetValidUser(tbUserID.Text, tbPassword.Text, UserName)

            If UserID = 0 Then
                MsgBox("Invalid User Name or Password", MsgBoxStyle.Critical, "Inventory Manager")
                tbUserID.Focus()
            End If

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        Return UserID

    End Function
    Dim mainform As frmMain
    Sub CheckLogin()

        If toCheckUserNameAndPassword() = 0 Then
            Exit Sub
        Else
            CashierID = Integer.Parse(tbUserID.Text)
            tbPassword.Clear()
            Me.Hide()
            mainform = New frmMain
            mainform.ShowDialog()
        End If

    End Sub

    Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
        CheckLogin()
    End Sub

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Close()
        Application.Exit()
    End Sub

    Private Sub txtPass_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbPassword.KeyDown
        If e.KeyCode = Keys.Enter Then
            CheckLogin()
        End If
    End Sub

    Private Sub tbUserID_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbUserID.KeyDown
        If e.KeyCode = Keys.Enter Then
            tbPassword.Focus()
        End If
    End Sub

    
End Class
